import React from "react"; //必须存在

export default class Menuitem extends React.Component {
  constructor(props) {
    super(props);
    this.state = {};
  }

  changeItem = (data) => {
    this.props.changeItem(data);
  };

  render() {
    const { data } = this.props;
    return (
      <div className={"items" + data.id}>
        <ul v-if={data.children && data.children.length ? 1 : 0}>
          <li onClick={() => this.changeItem(data)}>{data.name}</li>
          {data.children.map((item, index) => (
            <Menuitem key={item.id} data={item} changeItem={this.changeItem} />
          ))}
        </ul>
      </div>
    );
  }
}
